package Boundary;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static Control.Control.Add_Component;
/**
 * @author Group77
 * @version 2.0
 * @description display a diagram for student's course
 */
public class Start extends Overall {
    public Start(int number) {
        super("Login_frame");

        JLabel label1 = new JLabel("Start your journey!", JLabel.CENTER);
        label1.setFont(new Font("TimesRoman", Font.ITALIC, 30));
        JPanel empty1 = new JPanel();
        empty1.setPreferredSize(new Dimension(100, 10));
        empty1.setBorder(BorderFactory.createEmptyBorder());
//        panel1.add(empty1, BorderLayout.NORTH);
        panel1.add(label1, BorderLayout.CENTER);
        Add_Component(jfr, gbl, panel1, gbc, 0, 0, 1, 4, 0, 0);

        //component2 test
        panel2.setBorder(BorderFactory.createEmptyBorder());
        JButton button1 = new JButton("Module");
        button1.setPreferredSize(new Dimension(200,50));
        button1.setBorder(BorderFactory.createRaisedBevelBorder());
        button1.setBackground(Color.LIGHT_GRAY);
        button1.setFont(new Font("TimesRoman", Font.BOLD, 30));
        panel2.add(button1, BorderLayout.WEST);
        JPanel empty = new JPanel();
        empty.setPreferredSize(new Dimension(0, 0));
        empty.setBorder(BorderFactory.createEmptyBorder());
        panel2.add(empty, BorderLayout.EAST);
        Add_Component(jfr, gbl, panel2, gbc, 0, 1, 1, 2, 1, 0);
        button1.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        jfr.setVisible(false);
                        new ModulesManagement(number);
                        jfr.dispose();
                    }
                }
        );
        JButton button2 = new JButton("Role");
        button2.setPreferredSize(new Dimension(200,50));
        button2.setBorder(BorderFactory.createRaisedBevelBorder());
        button2.setBackground(Color.LIGHT_GRAY);
        button2.setFont(new Font("TimesRoman", Font.BOLD, 30));
        panel3.add(button2, BorderLayout.CENTER);
        JPanel empty2 = new JPanel();
        empty2.setPreferredSize(new Dimension(0, 0));
        empty2.setBorder(BorderFactory.createEmptyBorder());
        panel3.add(empty2);
        Add_Component(jfr, gbl, panel3, gbc, 0, 2, 1, 2, 1, 0);
        button2.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        jfr.setVisible(false);
                        new RolesManagement(number);
                        jfr.dispose();
                    }
                }
        );
        JButton button3 = new JButton("Achievement");
        button3.setPreferredSize(new Dimension(200,50));
        button3.setBorder(BorderFactory.createRaisedBevelBorder());
        button3.setBackground(Color.LIGHT_GRAY);
        button3.setFont(new Font("TimesRoman", Font.BOLD, 30));
        panel4.add(button3, BorderLayout.CENTER);
        JPanel empty3 = new JPanel();
        empty3.setPreferredSize(new Dimension(0, 0));
        empty3.setBorder(BorderFactory.createEmptyBorder());
        panel4.add(empty3);
        Add_Component(jfr, gbl, panel4, gbc, 0, 3, 1, 2, 1, 0);
        button3.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        jfr.setVisible(false);
                        new AchieveManagement(number);
                        jfr.dispose();
                    }
                }
        );

        //go back
//        panel5.setLayout(new BorderLayout());
//        panel5.setBorder(BorderFactory.createEmptyBorder());
        JButton button0 = new JButton("   Go back   ");
        button0.setPreferredSize(new Dimension(200,50));
        button0.setBorder(BorderFactory.createRaisedBevelBorder());
        button0.setBackground(Color.cyan);
        button0.setFont(new Font("STSong", Font.BOLD, 30));

        JPanel empty9 = new JPanel();
        empty9.setPreferredSize(new Dimension(0, 0));
        panel5.add(button0, BorderLayout.CENTER);
        panel5.add(empty9, BorderLayout.SOUTH);
//        panel1.add(label9, BorderLayout.EAST);
        Add_Component(jfr, gbl, panel5, gbc, 0, 4, 1, 2, 1, 0);


        button0.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        jfr.setVisible(false);
                        new Student_Login();
                        jfr.dispose();
                    }
                }
        );


//classes
        String[] columnNames = {"","Monday","Tuesday","Wednesday","Thursday","Friday"};
        String[][] rowData = {{"<html><body><p style='text-indent:2em" +
                "'>1</body></html>","","Geography","History","","Internet"},
                {"2","","Geography","History","","Internet"},
                {"3","Math","","","Math","Science"},
                {"4","Math","","","Math","Science"},
                {"5","","","","",""},
                {"6","History","","Math","PE",""},
                {"7","History","","Math","PE","Geography"},
                {"8","History","Art","Math","PE","Geography"},
                {"9","","Art","","","Art"},
                {"10","Science","","","","Art"},
                {"11","Science","","","",""},
                {"12","","","","",""},
                {"13","","History","","",""},
                {"14","","History","","Internet",""}

        };
        JTable table1 = new JTable (rowData, columnNames);
        table1.setForeground(Color.BLACK);
        table1.setFont(new Font(null, Font.PLAIN, 14));
        table1.setSelectionForeground(Color.DARK_GRAY);
        table1.setSelectionBackground(Color.cyan);
        table1.setGridColor(Color.GRAY);
        table1.setBackground(Color.white);
        table1.getTableHeader().setFont(new Font(null, Font.BOLD, 14));
        table1.getTableHeader().setForeground(Color.BLACK);
        table1.getTableHeader().setBackground(new Color(113,191,234));
        table1.getTableHeader().setResizingAllowed(false);
        table1.getTableHeader().setReorderingAllowed(false);
        table1.setRowHeight(30);
        table1.getColumnModel().getColumn(0).setPreferredWidth(40);
        JScrollPane scrollPane = new JScrollPane(table1);
        table1.setPreferredScrollableViewportSize(new Dimension(400, 420));

        panel7.add(scrollPane, BorderLayout.CENTER);
        JPanel empty5 = new JPanel();
        empty5.setPreferredSize(new Dimension(0, 0));
        empty5.setBorder(BorderFactory.createEmptyBorder());
        panel7.add(empty5);
        Add_Component(jfr, gbl, panel7, gbc, 2, 1, 4, 2, 1, 0);


    }


}
